package com.qezhhnjy.bilibili.entity;

import lombok.AllArgsConstructor;
import lombok.Data;
import lombok.NoArgsConstructor;

/**
 * @author zhaoyangfu - 2021/4/3 15:11
 */
@Data
@AllArgsConstructor
@NoArgsConstructor
public class CommonResult<T> {

    private Integer code;
    private String message;
    private T data;

    public CommonResult(Integer code, String message) {
        this(code, message, null);
    }

    public static <T> CommonResult<T> success(T data) {
        return new CommonResult<>(200, "响应成功", data);
    }

    public static CommonResult<Void> success() {
        return new CommonResult<>(200, "响应成功");
    }

    public static CommonResult<Void> error(String message) {
        return new CommonResult<>(500, message);
    }

}
